package com.clw.practice.jol;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class Test {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        MyThread mt1=new MyThread();
        MyThread mt2=new MyThread();
        FutureTask<String> task1=new FutureTask<String>(mt1);
        FutureTask<String> task2=new FutureTask<String>(mt2);

        //FutureTask是Runnable接口的实现类/子类，所以Thread构造方法可以接收其对象
        new Thread(task1).start();
        new Thread(task2).start();

        //FutureTask同时是Future接口的实现类/子类，父接口的get方法可以获取其值
        System.out.println("A"+task1.get());
        System.out.println("B"+task2.get());
    }
}